/*
 * @Date: 2023-02-11 19:41:08
 * @LastEditors: Zireael 1193875164@qq.com
 * @LastEditTime: 2023-02-11 19:46:03
 * @FilePath: \A19\backend\src\api\Get\ApiGetCreatedCourses.ts
 */
import { Global } from './../../Global/index';
import { ApiCall } from "tsrpc";
import { ReqGetCreatedCourses, ResGetCreatedCourses } from "../../shared/protocols/Get/PtlGetCreatedCourses";

export default async function (call: ApiCall<ReqGetCreatedCourses, ResGetCreatedCourses>) {

    const teacher = call.currentUser
    const ret = await Global.collection('courses').find({
        teacher: teacher._id
    }).toArray()

    call.succ({
        courses: ret
    })

}